updating oE mod

mod

include math.e 
namespace math 
public function mod(object x, object y) 

computes the remainder of the division of two objects using floored division.

Parameters:
  1. dividend : any Euphoria object.
  2. divisor : any Euphoria object.
Returns:

An object, the shape of which depends on dividend's and divisor's. For two atoms, this is the remainder of dividing dividend by divisor, with divisor's sign.

Comments:
  • There is a integer N such that dividend = N * divisor + result.
  • The result is non-negative and has lesser magnitude than divisor. n needs not fit in an Euphoria integer.
  • The result has the same sign as the dividend.
  • The arguments to this function may be atoms or sequences. The rules for operations on sequences apply, and determine the shape of the returned object.
  • When both arguments have the same sign, mod() and remainder return the same result.
  • This differs from remainder in that when the operands' signs are different this function rounds dividend/divisior away from zero whereas remainder rounds towards zero.
Example 1:
a = mod(9, 4) 
-- a is 1 
Example 2:
s = mod({81, -3.5, -9, 5.5}, {8, -1.7, 2, -4}) 
-- s is {1,-0.1,1,-2.5} 
Example 3:
s = mod({17, 12, 34}, 16) 
-- s is {1, 12, 2} 
Example 4:
s = mod(16, {2, 3, 5}) 
-- s is {0, 1, 1} 
See Also:

remainder, Relational operators, Operations on sequences

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu